<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\ApiResponse;
use App\Http\Controllers\Controller;
use App\News;
use Illuminate\Http\Request;

class NewsController extends Controller
{
    use ApiResponse;
    public function index(Request $request)
    {
        $result=News::latest()->paginate($request->get('size',10));
        return $this->data($result);
    }
    public function show($id)
    {
       $result=News::where([['id','=',$id],['status','=',1]]);
       if (!$result){
           return $this->message_error("新闻已删除");
       }
       return $this->data($result);
    }
}
